home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 126-150 / disk_136 / yaboingii / ybspr.c < prev   
C/C++ Source or Header  |  1992-05-06  |  5KB  |  134 lines

  1. /* ybspr.c (c)1988 Ali T. Ozer
  2. ** Sprite stuff for YaBoing II
  3. ** Freely distributable.
  4. */
  5.  
  6. #include "yb2.h"
  7.  
  8. #define IMAGEHEIGHT 20
  9.  
  10. unsigned short sprimages[OPVALUE+OPVALUES][IMAGEHEIGHT] = {
  11. {0x00e0,0x071c,0x0e0e,0x0e0e,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,
  12.  0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x0e0e,0x0e0e,0x071c,0x00e0},
  13. {0x0020,0x00e0,0x0fe0,0x0ce0,0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,
  14.  0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x0ffe,0x0ffe},
  15. {0x01e0,0x07fc,0x1c1e,0x1c1f,0x1e0f,0x1e0f,0x0c0f,0x000f,0x001e,0x001e,
  16.  0x003c,0x0070,0x00e0,0x01c1,0x0181,0x0203,0x07ff,0x0fff,0x1ffe,0x1ffe},
  17. {0x01e0,0x07fc,0x0e1e,0x0e1e,0x0e1e,0x0e1e,0x001e,0x003c,0x0078,0x01f8,
  18.  0x001e,0x001f,0x000f,0x000f,0x1c0f,0x1e0f,0x1e1f,0x1c1e,0x0ffc,0x01e0},
  19. {0x0018,0x0038,0x0078,0x0078,0x00b8,0x01b8,0x0338,0x0638,0x0438,0x0838,
  20.  0x1838,0x3038,0x6038,0x7fff,0x0078,0x0078,0x0078,0x0078,0x03ff,0x03ff},
  21. {0x0402,0x07fc,0x07fc,0x07f0,0x07c0,0x0400,0x0400,0x0400,0x07f8,0x041e,
  22.  0x000e,0x000f,0x000f,0x1c0f,0x1c0f,0x1c0f,0x180f,0x0c1e,0x07fc,0x01e0},
  23. {0x0078,0x01fe,0x038e,0x070e,0x0e0e,0x1e00,0x1e00,0x1e00,0x1ef8,0x1f0e,
  24.  0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x0e0f,0x070e,0x03fc,0x00f0},
  25. {0x1fff,0x1fff,0x1ffe,0x1ffe,0x100c,0x3018,0x3030,0x0060,0x0060,0x00c0,
  26.  0x00c0,0x01c0,0x01c0,0x01c0,0x01c0,0x03c0,0x03c0,0x03c0,0x03c0,0x0180},
  27. {0x00f0,0x03fc,0x060e,0x0c06,0x0c06,0x0e06,0x0f8e,0x0fdc,0x07f0,0x03fc,
  28.  0x07fe,0x0e3f,0x1c1f,0x1807,0x1803,0x1803,0x1c07,0x0e06,0x07fc,0x01f0},
  29. {0x01e0,0x07f8,0x0f1c,0x1e0e,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,0x1e0f,
  30.  0x0e1f,0x03ef,0x000f,0x000f,0x000f,0x0e0e,0x0e1e,0x0e3c,0x07f0,0x03e0},
  31. /*** ADD ***/
  32. {0x0000,0x0000,0x0000,0x0000,0x00e0,0x00e0,0x00e0,0x00e0,0x0ffe,0x0ffe,
  33.  0x0ffe,0x00e0,0x00e0,0x00e0,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000},
  34. /*** POP ***/
  35. {0x0000,0x7e00,0x3300,0x3300,0x3300,0x3e00,0x31c0,0x3360,0x3630,0x7e30,
  36.  0x0630,0x067e,0x0633,0x0373,0x01f3,0x003e,0x0030,0x0030,0x0030,0x0078},
  37. /*** MUL ***/
  38. {0x0000,0x0000,0x0000,0x0000,0x0000,0x030c,0x079e,0x03fc,0x01f8,0x00f0,
  39.  0x01f8,0x03fc,0x079e,0x030c,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},
  40. /*** DIV ***/
  41. {0x0000,0x0000,0x0000,0x00e0,0x00e0,0x00e0,0x0000,0x0000,0x0ffe,0x0ffe,
  42.  0x0ffe,0x0000,0x0000,0x00e0,0x00e0,0x00e0,0x0000,0x0000,0x0000,0x0000},
  43. /*** SWP ***/
  44. {0x3800,0x6def,0x60c6,0x3cc6,0x06c6,0x06d6,0x66d6,0x66d6,0x3c7c,0x006c,
  45.  0x0c00,0x1e7e,0x3333,0x3333,0x3333,0x3f3e,0x3330,0x3330,0x7eb0,0x0078},
  46. /*** SUB ***/
  47. {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0ffe,0x0ffe,
  48.  0x0ffe,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},
  49. /*** Question Mark ***/
  50. {0x00e0,0x03f8,0x061c,0x0f1e,0x0f1e,0x0f1e,0x001e,0x003c,0x0070,0x0060,
  51.  0x00c0,0x00c0,0x00c0,0x00c0,0x0000,0x00c0,0x01e0,0x01e0,0x01e0,0x00c0} 
  52. };
  53.  
  54. /* Assuming we have enough bytes in the sprite area...
  55. ** Loads specified image into the memory area provided.
  56. */
  57. void LoadSpriteImage (sprmem, image)
  58. unsigned short *sprmem;
  59. int image;
  60. {
  61.   register int cnt;
  62.   unsigned short *imem = sprimages[image];  
  63.   sprmem += 2;
  64.   for (cnt = 0; cnt < IMAGEHEIGHT; cnt++) {
  65.     *sprmem++ = *imem << 1;
  66.     *sprmem++ = *imem++;
  67.   }
  68.   *sprmem++ = 0;
  69.   *sprmem++ = 0;
  70. }
  71.  
  72. /* Applies the given mask to the image.
  73. */
  74. void DissolveSprite (sprmem, dissolvemask)
  75. unsigned short *sprmem, dissolvemask;
  76. {
  77.   register int cnt;
  78.   sprmem += 2;
  79.   for (cnt = 0; cnt < IMAGEHEIGHT+IMAGEHEIGHT; cnt++) *sprmem++ &= dissolvemask;
  80. }
  81.  
  82. /* Obtains and initializes the specified sprite.
  83. */
  84. int InitSprite (spr, sprnum)
  85. struct sprrec *spr;
  86. int sprnum;
  87. {
  88.   if ((GetSprite (&(spr->actualsprite), (long)sprnum) != -1) &&
  89.       ((spr->sprmem = AllocMem ((long)((IMAGEHEIGHT*2+4)*2), MEMF_CHIP | MEMF_CLEAR)) != NULL))
  90.     return (1);
  91.   else return (0);
  92. }
  93.  
  94. /* Gives the sprite back to the system.
  95. */
  96. void ReleaseSprite (spr)
  97. struct sprrec *spr;
  98. {
  99.   if (spr->actualsprite.num != -1) FreeSprite ((long)(spr->actualsprite.num));
  100.   if (spr->sprmem != NULL) FreeMem (spr->sprmem, (long)((IMAGEHEIGHT*2+4)*2));
  101. }
  102.  
  103. /* Makes the sprite visible/invisible...
  104. */
  105. void ShowSprite (spr, show)
  106. struct sprrec *spr;
  107. int show;
  108. {
  109.   spr->actualsprite.height = (show ? IMAGEHEIGHT : 0);
  110.   ChangeSprite (NULL, &(spr->actualsprite), spr->sprmem);
  111. }
  112.  
  113.  
  114. /* The following SHOULD go into CHIP RAM, so link with "+cd"
  115. */
  116. unsigned short timepointer[] = {
  117.   0x0000,0x0000,
  118.   0x0000,0xffff,0x4800,0xffff,0x634c,0xffff,0x4aae,
  119.   0xffff,0x4aa8,0xffff,0x2a26,0xffff,0x0000,0xffff,
  120.   0x0000,0x0000
  121. };
  122.  
  123. /* Changes the mouse pointer into the "time" pointer
  124. */
  125. void SetWarnPointer (win, show)
  126. struct Window *win;
  127. int show;
  128. {
  129.   if (show) SetPointer (win, &timepointer[0], 7L, 16L, -7L, -3L);
  130.   else ClearPointer (win);
  131. }
  132.  
  133.     
  134.